const { defineConfig } = require('@vue/cli-service');
const webpack = require('webpack');
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = defineConfig({
  lintOnSave: false,  // 添加此行，关闭保存时的 lint 检查
  transpileDependencies: true,
  configureWebpack: {
    plugins: [
      new webpack.DefinePlugin({
        __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(false)
      })
    ],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    },
    optimization: {
      minimize: true, // 确保开启代码压缩
      minimizer: [
        new TerserPlugin({
          terserOptions: {
            compress: {
              drop_console: true, // 删除所有的 console.log 和 console.* 调用
              drop_debugger: true, // 删除 debugger
            },
            output: {
              comments: false, // 删除所有注释
            },
          },
        }),
      ],
    },
  },
  devServer: {
    proxy: {
      '/amsp': {
        target: 'http://192.168.110.2:8081', // 开发环境接口地址
        // target: 'http://192.168.110.27:8081', // 测试环境接口地址
        changeOrigin: true,
        pathRewrite: {
          '^/amsp': ''
        }
      },
    },
  },
});
